//防止短时间内多次点击，防抖
var clickTag=true;
function submit() {
    if(!clickTag){
        alert("正在发布中！");
        return;
    }
    var title = $("#title").val();
    var content = $("#content").val();


    if (!validForm()) {
        alert("请完善必填信息");
        return;
    }

    console.log("title:", title);
    console.log("content:", content);

    var postData={
        title:title,
        content:content,
    };
    clickTag=false;
    $.ajax({
        type: "POST",
        url: urlcore + "/api/message/add",
        dataType: "json",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(postData),
        success: function (data) {
            clickTag=true;
            alert("添加成功！");
            window.location.href="sysmsg_list.html";
        },
        error: function () {
            clickTag=true;
            alert("error")
        }
    });

    //校验表单
    function validForm() {
        var result = true;
        if (title == "" || content == "") {
            return false;
        }
        return result;
    }

}

